import { WXRequest } from "./request"
const wxreq = new WXRequest()
export async function login(username,phone) {
  const data = { username,phone }
  const url = `/applet/user/login`
  const res = await wxreq.post({ url, data })
  return res
}
/**
 * 添加地址
 * @param {*} username 
 * @param {*} phone 
 * @param {*} area 
 * @param {*} address 
 * @param {*} openId 
 */
export async function addAddress(username,phone,area,address,openId) {
  const data = { username,phone,area,address,openId}
  const url = `/applet/user/addAddress`
  const res = await wxreq.post({ url, data })
  return res
}

/**
 * 更新地址
 * @param {*} id 
 * @param {*} username 
 * @param {*} phone 
 * @param {*} area 
 * @param {*} address 
 * @param {*} openId 
 */
export async function updateAddress(id,username,phone,area,address,openId) {
  const data = {id,username,phone,area,address,openId}
  const url = `/applet/common/updateAddress`
  const res = await wxreq.post({ url, data })
  return res
}


/**
 * 获取地址列表
 */
export async function getAddress() {
  let openId = ''
  const data = {openId}
  const url = `/applet/common/getAddress`
  const res = await wxreq.post({ url, data })
  return res
}

/**
 * 获取商品列表
 * @param {*} group 
 * @param {*} groupType 
 */
export async function getGoodsList(group,groupType) {
  const data = {group,groupType}
  const url = `/applet/common/getGoodsList`
  const res = await wxreq.post({ url, data })
  return res
}

/**
 * 根据商品ID获取商品信息
 * @param {*} id 
 */
export async function getGoodsById(id) {
  const data = {id}
  const url = `/applet/common/getGoodsById`
  const res = await wxreq.post({ url, data })
  return res
}

export async function addBag(goodsId,img,money,goodsName) {
  const data = {goodsId,img,money,goodsName}
  const url = `/applet/common/addBag`
  const res = await wxreq.post({ url, data })
  return res
}

export async function getShopCarList() {
  let openId = ''
  const data = {openId}
  const url = `/applet/common/getShopCarList`
  const res = await wxreq.post({ url, data })
  return res
}




